package config

import (
	"fmt"
	"github.com/spf13/viper"
)

var LogConfig *logConfig

type logConfig struct {
	Level      string `mapstructure:"level"`
	Filename   string `mapstructure:"filename"`
	MaxSize    int    `mapstructure:"max_size"`
	MaxAge     int    `mapstructure:"max_age"`
	MaxBackups int    `mapstructure:"max_backups"`
}

func init() {
	LogConfig = new(logConfig)
	// 将读取的配置信息保存至全局变量Conf
	if err := viper.Sub("log").Unmarshal(LogConfig); err != nil {
		panic(fmt.Errorf("unmarshal log conf failed, err:%s \n", err))
	}
}
